import pygame
import sys
from init_map import InitMap


class Map(InitMap):
    def __init__(self, *args):
        InitMap.__init__(self)

        self.thief = pygame.image.load("../资源/图片/小偷.png").convert_alpha()
        self.key_yellow = pygame.image.load("../资源/图片/黄钥匙.jpg").convert_alpha()
        self.door_yellow = pygame.image.load("../资源/图片/黄门.jpg").convert_alpha()
        self.door_blue = pygame.image.load("../资源/图片/蓝门.png").convert_alpha()
        self.door_red = pygame.image.load("../资源/图片/红门.jpg").convert_alpha()
        self.door_iron = pygame.image.load("../资源/图片/铁门.png").convert_alpha()
        self.hp_red = pygame.image.load("../资源/图片/红药.jpg").convert_alpha()
        self.kulou = pygame.image.load("../资源/图片/骷髅怪.jpg").convert_alpha()
        self.gem_blue = pygame.image.load("../资源/图片/蓝宝石.jpg").convert_alpha()
        self.gem_red = pygame.image.load("../资源/图片/红宝石.jpg").convert_alpha()
        self.slm_red = pygame.image.load("../资源/图片/红史莱姆.jpg").convert_alpha()
        self.little_bat = pygame.image.load("../资源/图片/小蝙蝠.jpg").convert_alpha()
        self.black_head = pygame.image.load("../资源/图片/青头怪.jpg").convert_alpha()
        self.big_bat = pygame.image.load("../资源/图片/大蝙蝠.png").convert_alpha()
        self.animal_man = pygame.image.load("../资源/图片/兽面人.jpg").convert_alpha()
        self.primary_guard = pygame.image.load("../资源/图片/初级卫兵.png").convert_alpha()
        self.red_bat = pygame.image.load("../资源/图片/红蝙蝠.png").convert_alpha()

        self.hero_pos = (10, 9)
        self.up_pos = (0, 10)
        self.down_pos = (10, 10)
        self.variable_pos = {
            (0, 1): (self.door_yellow, '黄门'),
            (2, 1): (self.door_yellow, '黄门'),
            (8, 1): (self.door_yellow, '黄门'),
            (10, 1): (self.door_yellow, '黄门'),
            (4, 9): (self.key_yellow, '黄钥匙'),
            (6, 9): (self.key_yellow, '黄钥匙'),
            (2, 3): (self.kulou, '骷髅怪'),
            (8, 3): (self.kulou, '骷髅怪'),
            (4, 4): (self.gem_blue, '蓝宝石'),
            (6, 4): (self.gem_blue, '蓝宝石'),
            (4, 7): (self.gem_red, '红宝石'),
            (6, 7): (self.gem_red, '红宝石'),
            (0, 6): (self.slm_red, '红史莱姆'),
            (10, 6): (self.slm_red, '红史莱姆'),
            (0, 4): (self.little_bat, '小蝙蝠'),
            (0, 5): (self.little_bat, '小蝙蝠'),
            (10, 4): (self.little_bat, '小蝙蝠'),
            (10, 5): (self.little_bat, '小蝙蝠'),
            (3, 10): (self.black_head, '青头怪'),
            (7, 10): (self.black_head, '青头怪'),
            (1, 0): (self.black_head, '青头怪'),
            (9, 0): (self.black_head, '青头怪'),
            (5, 0): (self.thief, '小偷'),
            (5, 2): (self.door_iron, '铁门'),
            (5, 4): (self.big_bat, '大蝙蝠'),
            (4, 3): (self.big_bat, '大蝙蝠'),
            (6, 3): (self.big_bat, '大蝙蝠'),
            (5, 3): (self.red_bat, '红蝙蝠'),
            (5, 5): (self.door_red, '红门'),
            (4, 6): (self.animal_man, '兽面人'),
            (6, 6): (self.animal_man, '兽面人'),
            (5, 7): (self.animal_man, '兽面人'),
            (5, 6): (self.primary_guard, '初级卫兵'),
            (5, 8): (self.door_blue, '蓝门'),
            (2, 4): (self.hp_red, '红药'),
            (2, 5): (self.hp_red, '红药'),
            (8, 4): (self.hp_red, '红药'),
            (8, 5): (self.hp_red, '红药'),
        }

    def fixed_brick(self):
        self.draw(self.upstairs, self.up_pos[0], self.up_pos[1])
        self.dic[self.up_pos] = '上楼'
        self.draw(self.downstairs, self.down_pos[0], self.down_pos[1])
        self.dic[self.down_pos] = '下楼'
        for i in range(1, 11):
            self.draw(self.wall, 1, i)
            self.dic[(1, i)] = '墙'
            self.draw(self.wall, 9, i)
            self.dic[(9, i)] = '墙'
        for i in range(10):
            self.draw(self.wall, 3, i)
            self.dic[(3, i)] = '墙'
            self.draw(self.wall, 7, i)
            self.dic[(7, i)] = '墙'
        for i in [(4, 2), (6, 2), (4, 5), (6, 5), (4, 8), (6, 8)]:
            self.draw(self.wall, i[0], i[1])
            self.dic[(i[0], i[1])] = '墙'
        for i in self.ls:
            self.screen.blit(self.road, i)
            self.dic[(int((i[0]-375)/48), int((i[1]-25)/48))] = '路'
